In [1]:
import tensorflow as tf
import numpy
import scipy.io
import time

sessione = tf.Session()

percorsoDati = "/home/protoss/Documenti/TESI/wn100bkp/data/dati9mesi52HWI.mat"

tFft = 8192
tObs = 9 #mesi
tObs = tObs*30*24*60*60
enhancement = 10
stepFrequenza = 1/tFft
spindownMin = -1e-9
spindownMax = 1e-10
stepSpindown = stepFrequenza/tObs
securbelt = 4000
epoca = (57722+57990)/2 

struttura = scipy.io.loadmat(percorsoDati)['job_pack_0']

frequenze = struttura['peaks'][0,0][1]
stepFreqRaffinato =  stepFrequenza/enhancement
freqMin = numpy.amin(frequenze)
freqMax = numpy.amax(frequenze)
freqIniz = freqMin- stepFrequenza/2 - stepFreqRaffinato
freqFin = freqMax + stepFrequenza/2 + stepFreqRaffinato
nstepFrequenze = numpy.ceil((freqFin-freqIniz)/stepFreqRaffinato)+securbelt
frequenze = frequenze-freqIniz
frequenze = (frequenze/stepFreqRaffinato)-round(enhancement/2+0.001)
 
nstepSpindown = numpy.round((spindownMax-spindownMin)/stepSpindown).astype(numpy.int32)
spindowns = numpy.arange(0, nstepSpindown)
spindowns = numpy.multiply(spindowns,stepSpindown)
spindowns = numpy.add(spindowns, spindownMin)

tempi = struttura['peaks'][0,0][0]

tempi = tempi-epoca
tempi = ((tempi)*3600*24/stepFreqRaffinato)

pesi = (struttura['peaks'][0,0][4]+1)

securbelt = numpy.float32(securbelt)
tempi = tempi.astype(numpy.float32)
pesi = pesi.astype(numpy.float32)
spindowns = spindowns.astype(numpy.float32)
frequenze = frequenze.astype(numpy.float32)
nRows = numpy.int32(nstepSpindown)
nColumns = numpy.int32(nstepFrequenze)

usando solo costanti


In [2]:
def mapnonVar(stepIesimo):
    sdTimed = tf.multiply(spindownsTF[stepIesimo], tempiTF, name = "Tdotpert")
    
    appoggio = tf.round(frequenzeTF-sdTimed+securbeltTF/2, name = "appoggioperindici")
    appoggio = tf.cast(appoggio, dtype=tf.int32)
    
    valori = tf.unsorted_segment_sum(pesiTF, appoggio, nColumns)
    return valori

securbeltTF = tf.constant(securbelt,dtype=tf.float32)
tempiTF = tf.constant(tempi,dtype=tf.float32)
pesiTF = tf.constant(pesi,dtype=tf.float32)
spindownsTF = tf.constant(spindowns, dtype=tf.float32)
frequenzeTF = tf.constant(frequenze, dtype=tf.float32)

nRows = numpy.int32(nstepSpindown)
nColumns = numpy.int32(nstepFrequenze)

pesiTF = tf.reshape(pesiTF,(1,tf.size(pesi)))
pesiTF = pesiTF[0]

houghLeft = tf.map_fn(mapnonVar, tf.range(0, nRows), dtype=tf.float32, parallel_iterations=8)
houghRight = houghLeft[:,enhancement:nColumns]-houghLeft[:,0:nColumns - enhancement]
houghDiff = tf.concat([houghLeft[:,0:enhancement],houghRight],1)
houghMap = tf.cumsum(houghDiff, axis = 1)


%time image = sessione.run(houghMap)

In [7]:
from matplotlib import pyplot
%matplotlib notebook

a = pyplot.imshow(image, origin = 'lower', aspect = 200)


con placeholders


In [3]:
def mapnonVar(stepIesimo):
    sdTimed = tf.multiply(spindownsTF[stepIesimo], tempiTF, name = "Tdotpert")
    
    appoggio = tf.round(frequenzeTF-sdTimed+securbeltTF/2, name = "appoggioperindici")
    appoggio = tf.cast(appoggio, dtype=tf.int32)
    
    valori = tf.unsorted_segment_sum(pesiTF, appoggio, nColumns)
    return valori

securbeltTF = tf.constant(securbelt,dtype = tf.float32, name = 'secur')
tempiTF = tf.placeholder(tf.float32, name = 't')
pesiTF = tf.placeholder(tf.float32, name = 'w')
spindownsTF = tf.placeholder(tf.float32, name = 'sd')
frequenzeTF = tf.placeholder(tf.float32, name = 'f')

nRows = numpy.int32(nstepSpindown)
nColumns = numpy.int32(nstepFrequenze)

pesiTF = tf.reshape(pesiTF,(1,tf.size(pesi)))
pesiTF = pesiTF[0]

dizionario = { 
               securbeltTF : securbelt,
               pesiTF : pesi,
               tempiTF : tempi,
               spindownsTF : spindowns,
               frequenzeTF : frequenze
             }

houghLeft = tf.map_fn(mapnonVar, tf.range(0, nRows), dtype=tf.float32, parallel_iterations=8)
houghRight = houghLeft[:,enhancement:nColumns]-houghLeft[:,0:nColumns - enhancement]
houghDiff = tf.concat([houghLeft[:,0:enhancement],houghRight],1)
houghMap = tf.cumsum(houghDiff, axis = 1)


%time image = sessione.run(houghMap, feed_dict = dizionario)

In [5]:
from matplotlib import pyplot
%matplotlib notebook

a = pyplot.imshow(image, origin = 'lower', aspect = 200)